package com.yxch.admin.controller;

import com.yxch.admin.model.commen.AuditLog;
import com.yxch.admin.model.commen.DictDTO;
import com.yxch.admin.service.CommenService;
import com.yxch.admin.utils.ResultAPI;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 枚举
 */
@RestController
@Slf4j
@RequestMapping("/yxch/admin/commen")
public class CommenController {
    @Autowired
    private CommenService commenService;

    @GetMapping
    public ResultAPI getEnumByName(@RequestParam(required = true) String name) {
        return commenService.getEnum(name);
    }

    @GetMapping("/list")
    public ResultAPI getEnumList(DictDTO dictDTO) {
        return commenService.getEnumList(dictDTO);
    }

    @PostMapping
    public ResultAPI AddandUpdateEnum(@RequestBody DictDTO dictDTO) {
        return commenService.AddandUpdateDictEnum(dictDTO);
    }

    @DeleteMapping("{ids}")
    public ResultAPI DeleteEnumById(@PathVariable("ids") List<Integer> ids) {
        return commenService.DeleteEnumById(ids);
    }

    /**
     * 获取审核日志（违规原因
     *
     * @param auditLog
     * @return
     */
    @GetMapping("/auditlog")
    public ResultAPI getAuditlog(AuditLog auditLog) {
        log.info(auditLog.toString());
        return commenService.getAuditlog(auditLog);
    }

    /**
     * 获取方向列表
     * @return
     */
    @GetMapping("direction")
    public ResultAPI getDirections() {
        return commenService.getDirections();
    }

}
